@milkdown/preset-commonmark 7.2.3 → 7.2.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/index.es.js +384 -390
- package/lib/index.es.js.map +1 -1
- package/lib/mark/emphasis.d.ts.map +1 -1
- package/lib/mark/link.d.ts.map +1 -1
- package/lib/mark/strong.d.ts.map +1 -1
- package/lib/node/blockquote.d.ts.map +1 -1
- package/lib/node/bullet-list.d.ts.map +1 -1
- package/lib/node/code-block.d.ts.map +1 -1
- package/lib/node/list-item.d.ts.map +1 -1
- package/lib/node/ordered-list.d.ts.map +1 -1
- package/lib/node/paragraph.d.ts.map +1 -1
- package/package.json +7 -8
- package/src/mark/emphasis.ts +2 -4
- package/src/mark/inline-code.ts +4 -4
- package/src/mark/link.ts +5 -5
- package/src/mark/strong.ts +2 -5
- package/src/node/blockquote.ts +2 -2
- package/src/node/bullet-list.ts +2 -2
- package/src/node/code-block.ts +2 -2
- package/src/node/hardbreak.ts +2 -2
- package/src/node/heading.ts +10 -10
- package/src/node/hr.ts +5 -5
- package/src/node/image.ts +6 -6
- package/src/node/list-item.ts +8 -7
- package/src/node/ordered-list.ts +3 -3
- package/src/node/paragraph.ts +1 -1
- package/src/plugin/hardbreak-clear-mark-plugin.ts +4 -4
- package/src/plugin/remark-marker-plugin.ts +2 -2
- package/src/plugin/sync-heading-id-plugin.ts +1 -1
- package/src/plugin/sync-list-order-plugin.ts +4 -4
package/lib/index.es.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { $markAttr as
|
|
2
|
-
import { remarkStringifyOptionsCtx as
|
|
3
|
-
import { toggleMark as
|
|
1
|
+
import { $markAttr as V, $markSchema as j, $command as h, $useKeymap as N, $node as Ye, $nodeAttr as I, $nodeSchema as C, $ctx as Z, $inputRule as w, pipe as At, $prose as O, $remark as $ } from "@milkdown/utils";
|
|
2
|
+
import { remarkStringifyOptionsCtx as Je, commandsCtx as y, editorViewCtx as X, serializerCtx as vt, parserCtx as Ht } from "@milkdown/core";
|
|
3
|
+
import { toggleMark as ee, setBlockType as _, wrapIn as te } from "@milkdown/prose/commands";
|
|
4
4
|
import { Fragment as Bt } from "@milkdown/prose/model";
|
|
5
|
-
import { expectDomTypeError as
|
|
6
|
-
import { textblockTypeInputRule as
|
|
7
|
-
import
|
|
8
|
-
import { TextSelection as
|
|
9
|
-
import {
|
|
5
|
+
import { expectDomTypeError as A } from "@milkdown/exception";
|
|
6
|
+
import { textblockTypeInputRule as Qe, wrappingInputRule as re, InputRule as Xe } from "@milkdown/prose/inputrules";
|
|
7
|
+
import Ot from "@sindresorhus/slugify";
|
|
8
|
+
import { TextSelection as G, Selection as Ze, PluginKey as T, Plugin as K } from "@milkdown/prose/state";
|
|
9
|
+
import { findSelectedNodeOfType as Tt } from "@milkdown/prose";
|
|
10
10
|
import { sinkListItem as Kt, liftListItem as et, splitListItem as Dt } from "@milkdown/prose/schema-list";
|
|
11
11
|
import { ReplaceStep as Rt, AddMarkStep as Pt } from "@milkdown/prose/transform";
|
|
12
12
|
import { Decoration as ze, DecorationSet as Ue } from "@milkdown/prose/view";
|
|
@@ -19,23 +19,23 @@ const tt = (t, e) => {
|
|
|
19
19
|
return;
|
|
20
20
|
}
|
|
21
21
|
const a = [];
|
|
22
|
-
e.content.forEach((s,
|
|
23
|
-
|
|
22
|
+
e.content.forEach((s, l, i) => {
|
|
23
|
+
i !== e.childCount - 1 && a.push(s);
|
|
24
24
|
}), t.next(Bt.fromArray(a));
|
|
25
25
|
}, n = (t, e) => (Object.assign(t, {
|
|
26
26
|
meta: {
|
|
27
27
|
package: "@milkdown/preset-commonmark",
|
|
28
28
|
...e
|
|
29
29
|
}
|
|
30
|
-
}), t), ne =
|
|
30
|
+
}), t), ne = V("emphasis");
|
|
31
31
|
n(ne, {
|
|
32
32
|
displayName: "Attr<emphasis>",
|
|
33
33
|
group: "Emphasis"
|
|
34
34
|
});
|
|
35
|
-
const
|
|
35
|
+
const z = j("emphasis", (t) => ({
|
|
36
36
|
attrs: {
|
|
37
37
|
marker: {
|
|
38
|
-
default: t.get(
|
|
38
|
+
default: t.get(Je).emphasis || "*"
|
|
39
39
|
}
|
|
40
40
|
},
|
|
41
41
|
parseDOM: [
|
|
@@ -59,27 +59,24 @@ const Y = z("emphasis", (t) => ({
|
|
|
59
59
|
}
|
|
60
60
|
}
|
|
61
61
|
}));
|
|
62
|
-
n(
|
|
62
|
+
n(z.mark, {
|
|
63
63
|
displayName: "MarkSchema<emphasis>",
|
|
64
64
|
group: "Emphasis"
|
|
65
65
|
});
|
|
66
|
-
n(
|
|
66
|
+
n(z.ctx, {
|
|
67
67
|
displayName: "MarkSchemaCtx<emphasis>",
|
|
68
68
|
group: "Emphasis"
|
|
69
69
|
});
|
|
70
|
-
const oe =
|
|
71
|
-
const e = Y.type(), r = t.get(U).emphasis || "*";
|
|
72
|
-
return Ze(e, r);
|
|
73
|
-
});
|
|
70
|
+
const oe = h("ToggleEmphasis", (t) => () => ee(z.type(t)));
|
|
74
71
|
n(oe, {
|
|
75
72
|
displayName: "Command<toggleEmphasisCommand>",
|
|
76
73
|
group: "Emphasis"
|
|
77
74
|
});
|
|
78
|
-
const se =
|
|
75
|
+
const se = N("emphasisKeymap", {
|
|
79
76
|
ToggleEmphasis: {
|
|
80
77
|
shortcuts: "Mod-i",
|
|
81
78
|
command: (t) => {
|
|
82
|
-
const e = t.get(
|
|
79
|
+
const e = t.get(y);
|
|
83
80
|
return () => e.call(oe.key);
|
|
84
81
|
}
|
|
85
82
|
}
|
|
@@ -92,15 +89,15 @@ n(se.shortcuts, {
|
|
|
92
89
|
displayName: "Keymap<emphasis>",
|
|
93
90
|
group: "Emphasis"
|
|
94
91
|
});
|
|
95
|
-
const le =
|
|
92
|
+
const le = V("strong");
|
|
96
93
|
n(le, {
|
|
97
94
|
displayName: "Attr<strong>",
|
|
98
95
|
group: "Strong"
|
|
99
96
|
});
|
|
100
|
-
const
|
|
97
|
+
const U = j("strong", (t) => ({
|
|
101
98
|
attrs: {
|
|
102
99
|
marker: {
|
|
103
|
-
default: t.get(
|
|
100
|
+
default: t.get(Je).strong || "*"
|
|
104
101
|
}
|
|
105
102
|
},
|
|
106
103
|
parseDOM: [
|
|
@@ -124,27 +121,24 @@ const J = z("strong", (t) => ({
|
|
|
124
121
|
}
|
|
125
122
|
}
|
|
126
123
|
}));
|
|
127
|
-
n(
|
|
124
|
+
n(U.mark, {
|
|
128
125
|
displayName: "MarkSchema<strong>",
|
|
129
126
|
group: "Strong"
|
|
130
127
|
});
|
|
131
|
-
n(
|
|
128
|
+
n(U.ctx, {
|
|
132
129
|
displayName: "MarkSchemaCtx<strong>",
|
|
133
130
|
group: "Strong"
|
|
134
131
|
});
|
|
135
|
-
const ie =
|
|
136
|
-
const e = J.type(), r = t.get(U).strong || "*", a = r + r;
|
|
137
|
-
return Ze(e, a);
|
|
138
|
-
});
|
|
132
|
+
const ie = h("ToggleStrong", (t) => () => ee(U.type(t)));
|
|
139
133
|
n(ie, {
|
|
140
134
|
displayName: "Command<toggleStrongCommand>",
|
|
141
135
|
group: "Strong"
|
|
142
136
|
});
|
|
143
|
-
const ce =
|
|
137
|
+
const ce = N("strongKeymap", {
|
|
144
138
|
ToggleBold: {
|
|
145
139
|
shortcuts: ["Mod-b"],
|
|
146
140
|
command: (t) => {
|
|
147
|
-
const e = t.get(
|
|
141
|
+
const e = t.get(y);
|
|
148
142
|
return () => e.call(ie.key);
|
|
149
143
|
}
|
|
150
144
|
}
|
|
@@ -157,12 +151,12 @@ n(ce.shortcuts, {
|
|
|
157
151
|
displayName: "Keymap<strong>",
|
|
158
152
|
group: "Strong"
|
|
159
153
|
});
|
|
160
|
-
const de =
|
|
154
|
+
const de = V("inlineCode");
|
|
161
155
|
n(de, {
|
|
162
156
|
displayName: "Attr<inlineCode>",
|
|
163
157
|
group: "InlineCode"
|
|
164
158
|
});
|
|
165
|
-
const
|
|
159
|
+
const x = j("inlineCode", (t) => ({
|
|
166
160
|
priority: 100,
|
|
167
161
|
code: !0,
|
|
168
162
|
inclusive: !1,
|
|
@@ -181,32 +175,32 @@ const b = z("inlineCode", (t) => ({
|
|
|
181
175
|
}
|
|
182
176
|
}
|
|
183
177
|
}));
|
|
184
|
-
n(
|
|
178
|
+
n(x.mark, {
|
|
185
179
|
displayName: "MarkSchema<inlineCode>",
|
|
186
180
|
group: "InlineCode"
|
|
187
181
|
});
|
|
188
|
-
n(
|
|
182
|
+
n(x.ctx, {
|
|
189
183
|
displayName: "MarkSchemaCtx<inlineCode>",
|
|
190
184
|
group: "InlineCode"
|
|
191
185
|
});
|
|
192
|
-
const me =
|
|
193
|
-
const { selection:
|
|
194
|
-
if (
|
|
186
|
+
const me = h("ToggleInlineCode", (t) => () => (e, r) => {
|
|
187
|
+
const { selection: a, tr: o } = e;
|
|
188
|
+
if (a.empty)
|
|
195
189
|
return !1;
|
|
196
|
-
const { from:
|
|
197
|
-
return
|
|
198
|
-
|
|
199
|
-
}),
|
|
190
|
+
const { from: s, to: l } = a;
|
|
191
|
+
return e.doc.rangeHasMark(s, l, x.type(t)) ? (r == null || r(o.removeMark(s, l, x.type(t))), !0) : (Object.keys(e.schema.marks).filter((d) => d !== x.type.name).map((d) => e.schema.marks[d]).forEach((d) => {
|
|
192
|
+
o.removeMark(s, l, d);
|
|
193
|
+
}), r == null || r(o.addMark(s, l, x.type(t).create())), !0);
|
|
200
194
|
});
|
|
201
195
|
n(me, {
|
|
202
196
|
displayName: "Command<toggleInlineCodeCommand>",
|
|
203
197
|
group: "InlineCode"
|
|
204
198
|
});
|
|
205
|
-
const ue =
|
|
199
|
+
const ue = N("inlineCodeKeymap", {
|
|
206
200
|
ToggleInlineCode: {
|
|
207
201
|
shortcuts: "Mod-e",
|
|
208
202
|
command: (t) => {
|
|
209
|
-
const e = t.get(
|
|
203
|
+
const e = t.get(y);
|
|
210
204
|
return () => e.call(me.key);
|
|
211
205
|
}
|
|
212
206
|
}
|
|
@@ -219,12 +213,12 @@ n(ue.shortcuts, {
|
|
|
219
213
|
displayName: "Keymap<inlineCode>",
|
|
220
214
|
group: "InlineCode"
|
|
221
215
|
});
|
|
222
|
-
const pe =
|
|
216
|
+
const pe = V("link");
|
|
223
217
|
n(pe, {
|
|
224
218
|
displayName: "Attr<link>",
|
|
225
219
|
group: "Link"
|
|
226
220
|
});
|
|
227
|
-
const
|
|
221
|
+
const B = j("link", (t) => ({
|
|
228
222
|
attrs: {
|
|
229
223
|
href: {},
|
|
230
224
|
title: { default: null }
|
|
@@ -234,7 +228,7 @@ const v = z("link", (t) => ({
|
|
|
234
228
|
tag: "a[href]",
|
|
235
229
|
getAttrs: (e) => {
|
|
236
230
|
if (!(e instanceof HTMLElement))
|
|
237
|
-
throw
|
|
231
|
+
throw A(e);
|
|
238
232
|
return { href: e.getAttribute("href"), title: e.getAttribute("title") };
|
|
239
233
|
}
|
|
240
234
|
}
|
|
@@ -257,31 +251,31 @@ const v = z("link", (t) => ({
|
|
|
257
251
|
}
|
|
258
252
|
}
|
|
259
253
|
}));
|
|
260
|
-
n(
|
|
254
|
+
n(B.mark, {
|
|
261
255
|
displayName: "MarkSchema<link>",
|
|
262
256
|
group: "Link"
|
|
263
257
|
});
|
|
264
|
-
const rt =
|
|
258
|
+
const rt = h("ToggleLink", (t) => (e = {}) => ee(B.type(t), e));
|
|
265
259
|
n(rt, {
|
|
266
260
|
displayName: "Command<toggleLinkCommand>",
|
|
267
261
|
group: "Link"
|
|
268
262
|
});
|
|
269
|
-
const at =
|
|
270
|
-
if (!
|
|
263
|
+
const at = h("UpdateLink", (t) => (e = {}) => (r, a) => {
|
|
264
|
+
if (!a)
|
|
271
265
|
return !1;
|
|
272
|
-
let
|
|
273
|
-
const { selection:
|
|
274
|
-
if (
|
|
275
|
-
if (
|
|
276
|
-
return
|
|
277
|
-
}), !
|
|
266
|
+
let o, s = -1;
|
|
267
|
+
const { selection: l } = r, { from: i, to: c } = l;
|
|
268
|
+
if (r.doc.nodesBetween(i, i === c ? c + 1 : c, (g, f) => {
|
|
269
|
+
if (B.type(t).isInSet(g.marks))
|
|
270
|
+
return o = g, s = f, !1;
|
|
271
|
+
}), !o)
|
|
278
272
|
return !1;
|
|
279
|
-
const
|
|
280
|
-
if (!
|
|
273
|
+
const d = o.marks.find(({ type: g }) => g === B.type(t));
|
|
274
|
+
if (!d)
|
|
281
275
|
return !1;
|
|
282
|
-
const
|
|
283
|
-
return
|
|
284
|
-
u.removeMark(
|
|
276
|
+
const m = s, p = s + o.nodeSize, { tr: u } = r, k = B.type(t).create({ ...d.attrs, ...e });
|
|
277
|
+
return k ? (a(
|
|
278
|
+
u.removeMark(m, p, d).addMark(m, p, k).setSelection(new G(u.selection.$anchor)).scrollIntoView()
|
|
285
279
|
), !0) : !1;
|
|
286
280
|
});
|
|
287
281
|
n(at, {
|
|
@@ -307,12 +301,12 @@ n(nt, {
|
|
|
307
301
|
displayName: "NodeSchema<doc>",
|
|
308
302
|
group: "Doc"
|
|
309
303
|
});
|
|
310
|
-
const ge =
|
|
304
|
+
const ge = I("paragraph");
|
|
311
305
|
n(ge, {
|
|
312
306
|
displayName: "Attr<paragraph>",
|
|
313
307
|
group: "Paragraph"
|
|
314
308
|
});
|
|
315
|
-
const
|
|
309
|
+
const v = C("paragraph", (t) => ({
|
|
316
310
|
content: "inline*",
|
|
317
311
|
group: "block",
|
|
318
312
|
parseDOM: [{ tag: "p" }],
|
|
@@ -330,24 +324,24 @@ const w = I("paragraph", (t) => ({
|
|
|
330
324
|
}
|
|
331
325
|
}
|
|
332
326
|
}));
|
|
333
|
-
n(
|
|
327
|
+
n(v.node, {
|
|
334
328
|
displayName: "NodeSchema<paragraph>",
|
|
335
329
|
group: "Paragraph"
|
|
336
330
|
});
|
|
337
|
-
n(
|
|
331
|
+
n(v.ctx, {
|
|
338
332
|
displayName: "NodeSchemaCtx<paragraph>",
|
|
339
333
|
group: "Paragraph"
|
|
340
334
|
});
|
|
341
|
-
const he =
|
|
335
|
+
const he = h("TurnIntoText", (t) => () => _(v.type(t)));
|
|
342
336
|
n(he, {
|
|
343
337
|
displayName: "Command<turnIntoTextCommand>",
|
|
344
338
|
group: "Paragraph"
|
|
345
339
|
});
|
|
346
|
-
const ye =
|
|
340
|
+
const ye = N("paragraphKeymap", {
|
|
347
341
|
TurnIntoText: {
|
|
348
342
|
shortcuts: "Mod-Alt-0",
|
|
349
343
|
command: (t) => {
|
|
350
|
-
const e = t.get(
|
|
344
|
+
const e = t.get(y);
|
|
351
345
|
return () => e.call(he.key);
|
|
352
346
|
}
|
|
353
347
|
}
|
|
@@ -360,18 +354,18 @@ n(ye.shortcuts, {
|
|
|
360
354
|
displayName: "Keymap<paragraph>",
|
|
361
355
|
group: "Paragraph"
|
|
362
356
|
});
|
|
363
|
-
const _t = Array(6).fill(0).map((t, e) => e + 1), $t = (t) =>
|
|
364
|
-
n(
|
|
357
|
+
const _t = Array(6).fill(0).map((t, e) => e + 1), $t = (t) => Ot(t.textContent), Y = Z($t, "headingIdGenerator");
|
|
358
|
+
n(Y, {
|
|
365
359
|
displayName: "Ctx<HeadingIdGenerator>",
|
|
366
360
|
group: "Heading"
|
|
367
361
|
});
|
|
368
|
-
const ke =
|
|
362
|
+
const ke = I("heading");
|
|
369
363
|
n(ke, {
|
|
370
364
|
displayName: "Attr<heading>",
|
|
371
365
|
group: "Heading"
|
|
372
366
|
});
|
|
373
|
-
const
|
|
374
|
-
const e = t.get(
|
|
367
|
+
const H = C("heading", (t) => {
|
|
368
|
+
const e = t.get(Y.key);
|
|
375
369
|
return {
|
|
376
370
|
content: "inline*",
|
|
377
371
|
group: "block",
|
|
@@ -388,7 +382,7 @@ const A = I("heading", (t) => {
|
|
|
388
382
|
tag: `h${r}`,
|
|
389
383
|
getAttrs: (a) => {
|
|
390
384
|
if (!(a instanceof HTMLElement))
|
|
391
|
-
throw
|
|
385
|
+
throw A(a);
|
|
392
386
|
return { level: r, id: a.id };
|
|
393
387
|
}
|
|
394
388
|
})),
|
|
@@ -415,17 +409,17 @@ const A = I("heading", (t) => {
|
|
|
415
409
|
}
|
|
416
410
|
};
|
|
417
411
|
});
|
|
418
|
-
n(
|
|
412
|
+
n(H.node, {
|
|
419
413
|
displayName: "NodeSchema<heading>",
|
|
420
414
|
group: "Heading"
|
|
421
415
|
});
|
|
422
|
-
n(
|
|
416
|
+
n(H.ctx, {
|
|
423
417
|
displayName: "NodeSchemaCtx<heading>",
|
|
424
418
|
group: "Heading"
|
|
425
419
|
});
|
|
426
|
-
const ot =
|
|
427
|
-
var
|
|
428
|
-
const r = ((
|
|
420
|
+
const ot = w((t) => Qe(/^(?<hashes>#+)\s$/, H.type(t), (e) => {
|
|
421
|
+
var l, i;
|
|
422
|
+
const r = ((i = (l = e.groups) == null ? void 0 : l.hashes) == null ? void 0 : i.length) || 0, a = t.get(X), { $from: o } = a.state.selection, s = o.node();
|
|
429
423
|
if (s.type.name === "heading") {
|
|
430
424
|
let c = Number(s.attrs.level) + Number(r);
|
|
431
425
|
return c > 6 && (c = 6), { level: c };
|
|
@@ -436,74 +430,74 @@ n(ot, {
|
|
|
436
430
|
displayName: "InputRule<wrapInHeadingInputRule>",
|
|
437
431
|
group: "Heading"
|
|
438
432
|
});
|
|
439
|
-
const
|
|
440
|
-
n(
|
|
433
|
+
const b = h("WrapInHeading", (t) => (e) => (e ?? (e = 1), e < 1 ? _(v.type(t)) : _(H.type(t), { level: e })));
|
|
434
|
+
n(b, {
|
|
441
435
|
displayName: "Command<wrapInHeadingCommand>",
|
|
442
436
|
group: "Heading"
|
|
443
437
|
});
|
|
444
|
-
const fe =
|
|
445
|
-
const { $from:
|
|
446
|
-
if (
|
|
438
|
+
const fe = h("DowngradeHeading", (t) => () => (e, r, a) => {
|
|
439
|
+
const { $from: o } = e.selection, s = o.node();
|
|
440
|
+
if (s.type !== H.type(t) || !e.selection.empty || o.parentOffset !== 0)
|
|
447
441
|
return !1;
|
|
448
|
-
const
|
|
449
|
-
return
|
|
450
|
-
|
|
451
|
-
...
|
|
452
|
-
level:
|
|
442
|
+
const l = s.attrs.level - 1;
|
|
443
|
+
return l ? (r == null || r(
|
|
444
|
+
e.tr.setNodeMarkup(e.selection.$from.before(), void 0, {
|
|
445
|
+
...s.attrs,
|
|
446
|
+
level: l
|
|
453
447
|
})
|
|
454
|
-
), !0) : _(
|
|
448
|
+
), !0) : _(v.type(t))(e, r, a);
|
|
455
449
|
});
|
|
456
450
|
n(fe, {
|
|
457
451
|
displayName: "Command<downgradeHeadingCommand>",
|
|
458
452
|
group: "Heading"
|
|
459
453
|
});
|
|
460
|
-
const Ne =
|
|
454
|
+
const Ne = N("headingKeymap", {
|
|
461
455
|
TurnIntoH1: {
|
|
462
456
|
shortcuts: "Mod-Alt-1",
|
|
463
457
|
command: (t) => {
|
|
464
|
-
const e = t.get(
|
|
465
|
-
return () => e.call(
|
|
458
|
+
const e = t.get(y);
|
|
459
|
+
return () => e.call(b.key, 1);
|
|
466
460
|
}
|
|
467
461
|
},
|
|
468
462
|
TurnIntoH2: {
|
|
469
463
|
shortcuts: "Mod-Alt-2",
|
|
470
464
|
command: (t) => {
|
|
471
|
-
const e = t.get(
|
|
472
|
-
return () => e.call(
|
|
465
|
+
const e = t.get(y);
|
|
466
|
+
return () => e.call(b.key, 2);
|
|
473
467
|
}
|
|
474
468
|
},
|
|
475
469
|
TurnIntoH3: {
|
|
476
470
|
shortcuts: "Mod-Alt-3",
|
|
477
471
|
command: (t) => {
|
|
478
|
-
const e = t.get(
|
|
479
|
-
return () => e.call(
|
|
472
|
+
const e = t.get(y);
|
|
473
|
+
return () => e.call(b.key, 3);
|
|
480
474
|
}
|
|
481
475
|
},
|
|
482
476
|
TurnIntoH4: {
|
|
483
477
|
shortcuts: "Mod-Alt-4",
|
|
484
478
|
command: (t) => {
|
|
485
|
-
const e = t.get(
|
|
486
|
-
return () => e.call(
|
|
479
|
+
const e = t.get(y);
|
|
480
|
+
return () => e.call(b.key, 4);
|
|
487
481
|
}
|
|
488
482
|
},
|
|
489
483
|
TurnIntoH5: {
|
|
490
484
|
shortcuts: "Mod-Alt-5",
|
|
491
485
|
command: (t) => {
|
|
492
|
-
const e = t.get(
|
|
493
|
-
return () => e.call(
|
|
486
|
+
const e = t.get(y);
|
|
487
|
+
return () => e.call(b.key, 5);
|
|
494
488
|
}
|
|
495
489
|
},
|
|
496
490
|
TurnIntoH6: {
|
|
497
491
|
shortcuts: "Mod-Alt-6",
|
|
498
492
|
command: (t) => {
|
|
499
|
-
const e = t.get(
|
|
500
|
-
return () => e.call(
|
|
493
|
+
const e = t.get(y);
|
|
494
|
+
return () => e.call(b.key, 6);
|
|
501
495
|
}
|
|
502
496
|
},
|
|
503
497
|
DowngradeHeading: {
|
|
504
498
|
shortcuts: ["Delete", "Backspace"],
|
|
505
499
|
command: (t) => {
|
|
506
|
-
const e = t.get(
|
|
500
|
+
const e = t.get(y);
|
|
507
501
|
return () => e.call(fe.key);
|
|
508
502
|
}
|
|
509
503
|
}
|
|
@@ -516,12 +510,12 @@ n(Ne.shortcuts, {
|
|
|
516
510
|
displayName: "Keymap<heading>",
|
|
517
511
|
group: "Heading"
|
|
518
512
|
});
|
|
519
|
-
const Ie =
|
|
513
|
+
const Ie = I("blockquote");
|
|
520
514
|
n(Ie, {
|
|
521
515
|
displayName: "Attr<blockquote>",
|
|
522
516
|
group: "Blockquote"
|
|
523
517
|
});
|
|
524
|
-
const q =
|
|
518
|
+
const q = C("blockquote", (t) => ({
|
|
525
519
|
content: "block+",
|
|
526
520
|
group: "block",
|
|
527
521
|
defining: !0,
|
|
@@ -548,21 +542,21 @@ n(q.ctx, {
|
|
|
548
542
|
displayName: "NodeSchemaCtx<blockquote>",
|
|
549
543
|
group: "Blockquote"
|
|
550
544
|
});
|
|
551
|
-
const st =
|
|
545
|
+
const st = w((t) => re(/^\s*>\s$/, q.type(t)));
|
|
552
546
|
n(st, {
|
|
553
547
|
displayName: "InputRule<wrapInBlockquoteInputRule>",
|
|
554
548
|
group: "Blockquote"
|
|
555
549
|
});
|
|
556
|
-
const Ce =
|
|
550
|
+
const Ce = h("WrapInBlockquote", (t) => () => te(q.type(t)));
|
|
557
551
|
n(Ce, {
|
|
558
552
|
displayName: "Command<wrapInBlockquoteCommand>",
|
|
559
553
|
group: "Blockquote"
|
|
560
554
|
});
|
|
561
|
-
const Me =
|
|
555
|
+
const Me = N("blockquoteKeymap", {
|
|
562
556
|
WrapInBlockquote: {
|
|
563
557
|
shortcuts: "Mod-Shift-b",
|
|
564
558
|
command: (t) => {
|
|
565
|
-
const e = t.get(
|
|
559
|
+
const e = t.get(y);
|
|
566
560
|
return () => e.call(Ce.key);
|
|
567
561
|
}
|
|
568
562
|
}
|
|
@@ -575,7 +569,7 @@ n(Me.shortcuts, {
|
|
|
575
569
|
displayName: "Keymap<blockquote>",
|
|
576
570
|
group: "Blockquote"
|
|
577
571
|
});
|
|
578
|
-
const be =
|
|
572
|
+
const be = I("codeBlock", () => ({
|
|
579
573
|
pre: {},
|
|
580
574
|
code: {}
|
|
581
575
|
}));
|
|
@@ -583,7 +577,7 @@ n(be, {
|
|
|
583
577
|
displayName: "Attr<codeBlock>",
|
|
584
578
|
group: "CodeBlock"
|
|
585
579
|
});
|
|
586
|
-
const W =
|
|
580
|
+
const W = C("code_block", (t) => ({
|
|
587
581
|
content: "text*",
|
|
588
582
|
group: "block",
|
|
589
583
|
marks: "",
|
|
@@ -600,7 +594,7 @@ const W = I("code_block", (t) => ({
|
|
|
600
594
|
preserveWhitespace: "full",
|
|
601
595
|
getAttrs: (e) => {
|
|
602
596
|
if (!(e instanceof HTMLElement))
|
|
603
|
-
throw
|
|
597
|
+
throw A(e);
|
|
604
598
|
return { language: e.dataset.language };
|
|
605
599
|
}
|
|
606
600
|
}
|
|
@@ -641,49 +635,49 @@ n(W.ctx, {
|
|
|
641
635
|
displayName: "NodeSchemaCtx<codeBlock>",
|
|
642
636
|
group: "CodeBlock"
|
|
643
637
|
});
|
|
644
|
-
const lt =
|
|
645
|
-
var
|
|
638
|
+
const lt = w((t) => Qe(/^```(?<language>[a-z]*)?[\s\n]$/, W.type(t), (e) => {
|
|
639
|
+
var r;
|
|
646
640
|
return {
|
|
647
|
-
language: ((
|
|
641
|
+
language: ((r = e.groups) == null ? void 0 : r.language) ?? ""
|
|
648
642
|
};
|
|
649
643
|
}));
|
|
650
644
|
n(lt, {
|
|
651
645
|
displayName: "InputRule<createCodeBlockInputRule>",
|
|
652
646
|
group: "CodeBlock"
|
|
653
647
|
});
|
|
654
|
-
const
|
|
655
|
-
n(
|
|
648
|
+
const Le = h("CreateCodeBlock", (t) => (e = "") => _(W.type(t), { language: e }));
|
|
649
|
+
n(Le, {
|
|
656
650
|
displayName: "Command<createCodeBlockCommand>",
|
|
657
651
|
group: "CodeBlock"
|
|
658
652
|
});
|
|
659
|
-
const qt =
|
|
653
|
+
const qt = h("UpdateCodeBlockLanguage", () => ({ pos: t, language: e } = { pos: -1, language: "" }) => (r, a) => t >= 0 ? (a == null || a(r.tr.setNodeAttribute(t, "language", e)), !0) : !1);
|
|
660
654
|
n(qt, {
|
|
661
655
|
displayName: "Command<updateCodeBlockLanguageCommand>",
|
|
662
656
|
group: "CodeBlock"
|
|
663
657
|
});
|
|
664
|
-
const
|
|
658
|
+
const xe = N("codeBlockKeymap", {
|
|
665
659
|
CreateCodeBlock: {
|
|
666
660
|
shortcuts: "Mod-Alt-c",
|
|
667
661
|
command: (t) => {
|
|
668
|
-
const e = t.get(
|
|
669
|
-
return () => e.call(
|
|
662
|
+
const e = t.get(y);
|
|
663
|
+
return () => e.call(Le.key);
|
|
670
664
|
}
|
|
671
665
|
}
|
|
672
666
|
});
|
|
673
|
-
n(
|
|
667
|
+
n(xe.ctx, {
|
|
674
668
|
displayName: "KeymapCtx<codeBlock>",
|
|
675
669
|
group: "CodeBlock"
|
|
676
670
|
});
|
|
677
|
-
n(
|
|
671
|
+
n(xe.shortcuts, {
|
|
678
672
|
displayName: "Keymap<codeBlock>",
|
|
679
673
|
group: "CodeBlock"
|
|
680
674
|
});
|
|
681
|
-
const Se =
|
|
675
|
+
const Se = I("image");
|
|
682
676
|
n(Se, {
|
|
683
677
|
displayName: "Attr<image>",
|
|
684
678
|
group: "Image"
|
|
685
679
|
});
|
|
686
|
-
const
|
|
680
|
+
const D = C("image", (t) => ({
|
|
687
681
|
inline: !0,
|
|
688
682
|
group: "inline",
|
|
689
683
|
selectable: !0,
|
|
@@ -702,7 +696,7 @@ const O = I("image", (t) => ({
|
|
|
702
696
|
tag: "img[src]",
|
|
703
697
|
getAttrs: (e) => {
|
|
704
698
|
if (!(e instanceof HTMLElement))
|
|
705
|
-
throw
|
|
699
|
+
throw A(e);
|
|
706
700
|
return {
|
|
707
701
|
src: e.getAttribute("src") || "",
|
|
708
702
|
alt: e.getAttribute("alt") || "",
|
|
@@ -715,11 +709,11 @@ const O = I("image", (t) => ({
|
|
|
715
709
|
parseMarkdown: {
|
|
716
710
|
match: ({ type: e }) => e === "image",
|
|
717
711
|
runner: (e, r, a) => {
|
|
718
|
-
const o = r.url, s = r.alt,
|
|
712
|
+
const o = r.url, s = r.alt, l = r.title;
|
|
719
713
|
e.addNode(a, {
|
|
720
714
|
src: o,
|
|
721
715
|
alt: s,
|
|
722
|
-
title:
|
|
716
|
+
title: l
|
|
723
717
|
});
|
|
724
718
|
}
|
|
725
719
|
},
|
|
@@ -734,54 +728,54 @@ const O = I("image", (t) => ({
|
|
|
734
728
|
}
|
|
735
729
|
}
|
|
736
730
|
}));
|
|
737
|
-
n(
|
|
731
|
+
n(D.node, {
|
|
738
732
|
displayName: "NodeSchema<image>",
|
|
739
733
|
group: "Image"
|
|
740
734
|
});
|
|
741
|
-
n(
|
|
735
|
+
n(D.ctx, {
|
|
742
736
|
displayName: "NodeSchemaCtx<image>",
|
|
743
737
|
group: "Image"
|
|
744
738
|
});
|
|
745
|
-
const it =
|
|
746
|
-
if (!
|
|
739
|
+
const it = h("InsertImage", (t) => (e = {}) => (r, a) => {
|
|
740
|
+
if (!a)
|
|
747
741
|
return !0;
|
|
748
|
-
const { src:
|
|
749
|
-
return i && r
|
|
742
|
+
const { src: o = "", alt: s = "", title: l = "" } = e, i = D.type(t).create({ src: o, alt: s, title: l });
|
|
743
|
+
return i && a(r.tr.replaceSelectionWith(i).scrollIntoView()), !0;
|
|
750
744
|
});
|
|
751
745
|
n(it, {
|
|
752
746
|
displayName: "Command<insertImageCommand>",
|
|
753
747
|
group: "Image"
|
|
754
748
|
});
|
|
755
|
-
const ct =
|
|
756
|
-
const
|
|
757
|
-
if (!
|
|
749
|
+
const ct = h("UpdateImage", (t) => (e = {}) => (r, a) => {
|
|
750
|
+
const o = Tt(r.selection, D.type(t));
|
|
751
|
+
if (!o)
|
|
758
752
|
return !1;
|
|
759
|
-
const { node:
|
|
760
|
-
return
|
|
753
|
+
const { node: s, pos: l } = o, i = { ...s.attrs }, { src: c, alt: d, title: m } = e;
|
|
754
|
+
return c !== void 0 && (i.src = c), d !== void 0 && (i.alt = d), m !== void 0 && (i.title = m), a == null || a(r.tr.setNodeMarkup(l, void 0, i).scrollIntoView()), !0;
|
|
761
755
|
});
|
|
762
756
|
n(ct, {
|
|
763
757
|
displayName: "Command<updateImageCommand>",
|
|
764
758
|
group: "Image"
|
|
765
759
|
});
|
|
766
|
-
const Wt =
|
|
760
|
+
const Wt = w((t) => new Xe(
|
|
767
761
|
/!\[(?<alt>.*?)]\((?<filename>.*?)\s*(?="|\))"?(?<title>[^"]+)?"?\)/,
|
|
768
|
-
(
|
|
769
|
-
const [
|
|
770
|
-
return
|
|
762
|
+
(e, r, a, o) => {
|
|
763
|
+
const [s, l, i = "", c] = r;
|
|
764
|
+
return s ? e.tr.replaceWith(a, o, D.type(t).create({ src: i, alt: l, title: c })) : null;
|
|
771
765
|
}
|
|
772
766
|
));
|
|
773
767
|
n(Wt, {
|
|
774
768
|
displayName: "InputRule<insertImageInputRule>",
|
|
775
769
|
group: "Image"
|
|
776
770
|
});
|
|
777
|
-
const we =
|
|
771
|
+
const we = I("hardbreak", (t) => ({
|
|
778
772
|
"data-is-inline": t.attrs.isInline
|
|
779
773
|
}));
|
|
780
774
|
n(we, {
|
|
781
775
|
displayName: "Attr<hardbreak>",
|
|
782
776
|
group: "Hardbreak"
|
|
783
777
|
});
|
|
784
|
-
const
|
|
778
|
+
const S = C("hardbreak", (t) => ({
|
|
785
779
|
inline: !0,
|
|
786
780
|
group: "inline",
|
|
787
781
|
attrs: {
|
|
@@ -809,35 +803,35 @@ const x = I("hardbreak", (t) => ({
|
|
|
809
803
|
}
|
|
810
804
|
}
|
|
811
805
|
}));
|
|
812
|
-
n(
|
|
806
|
+
n(S.node, {
|
|
813
807
|
displayName: "NodeSchema<hardbreak>",
|
|
814
808
|
group: "Hardbreak"
|
|
815
809
|
});
|
|
816
|
-
n(
|
|
810
|
+
n(S.ctx, {
|
|
817
811
|
displayName: "NodeSchemaCtx<hardbreak>",
|
|
818
812
|
group: "Hardbreak"
|
|
819
813
|
});
|
|
820
|
-
const Ae =
|
|
821
|
-
var
|
|
822
|
-
const { selection:
|
|
823
|
-
if (
|
|
824
|
-
const
|
|
825
|
-
if (
|
|
826
|
-
return
|
|
827
|
-
|
|
814
|
+
const Ae = h("InsertHardbreak", (t) => () => (e, r) => {
|
|
815
|
+
var s;
|
|
816
|
+
const { selection: a, tr: o } = e;
|
|
817
|
+
if (a.empty) {
|
|
818
|
+
const l = a.$from.node();
|
|
819
|
+
if (l.childCount > 0 && ((s = l.lastChild) == null ? void 0 : s.type.name) === "hardbreak")
|
|
820
|
+
return r == null || r(
|
|
821
|
+
o.replaceRangeWith(a.to - 1, a.to, e.schema.node("paragraph")).setSelection(Ze.near(o.doc.resolve(a.to))).scrollIntoView()
|
|
828
822
|
), !0;
|
|
829
823
|
}
|
|
830
|
-
return
|
|
824
|
+
return r == null || r(o.setMeta("hardbreak", !0).replaceSelectionWith(S.type(t).create()).scrollIntoView()), !0;
|
|
831
825
|
});
|
|
832
826
|
n(Ae, {
|
|
833
827
|
displayName: "Command<insertHardbreakCommand>",
|
|
834
828
|
group: "Hardbreak"
|
|
835
829
|
});
|
|
836
|
-
const ve =
|
|
830
|
+
const ve = N("hardbreakKeymap", {
|
|
837
831
|
InsertHardbreak: {
|
|
838
832
|
shortcuts: "Shift-Enter",
|
|
839
833
|
command: (t) => {
|
|
840
|
-
const e = t.get(
|
|
834
|
+
const e = t.get(y);
|
|
841
835
|
return () => e.call(Ae.key);
|
|
842
836
|
}
|
|
843
837
|
}
|
|
@@ -850,12 +844,12 @@ n(ve.shortcuts, {
|
|
|
850
844
|
displayName: "Keymap<hardbreak>",
|
|
851
845
|
group: "Hardbreak"
|
|
852
846
|
});
|
|
853
|
-
const He =
|
|
847
|
+
const He = I("hr");
|
|
854
848
|
n(He, {
|
|
855
849
|
displayName: "Attr<hr>",
|
|
856
850
|
group: "Hr"
|
|
857
851
|
});
|
|
858
|
-
const F =
|
|
852
|
+
const F = C("hr", (t) => ({
|
|
859
853
|
group: "block",
|
|
860
854
|
parseDOM: [{ tag: "hr" }],
|
|
861
855
|
toDOM: (e) => ["hr", t.get(He.key)(e)],
|
|
@@ -880,36 +874,36 @@ n(F.ctx, {
|
|
|
880
874
|
displayName: "NodeSchemaCtx<hr>",
|
|
881
875
|
group: "Hr"
|
|
882
876
|
});
|
|
883
|
-
const dt =
|
|
877
|
+
const dt = w((t) => new Xe(
|
|
884
878
|
/^(?:---|___\s|\*\*\*\s)$/,
|
|
885
|
-
(
|
|
886
|
-
const { tr:
|
|
887
|
-
return
|
|
879
|
+
(e, r, a, o) => {
|
|
880
|
+
const { tr: s } = e;
|
|
881
|
+
return r[0] && s.replaceWith(a - 1, o, F.type(t).create()), s;
|
|
888
882
|
}
|
|
889
883
|
));
|
|
890
884
|
n(dt, {
|
|
891
885
|
displayName: "InputRule<insertHrInputRule>",
|
|
892
886
|
group: "Hr"
|
|
893
887
|
});
|
|
894
|
-
const mt =
|
|
895
|
-
if (!
|
|
888
|
+
const mt = h("InsertHr", (t) => () => (e, r) => {
|
|
889
|
+
if (!r)
|
|
896
890
|
return !0;
|
|
897
|
-
const
|
|
891
|
+
const a = v.node.type(t).create(), { tr: o, selection: s } = e, { from: l } = s, i = F.type(t).create();
|
|
898
892
|
if (!i)
|
|
899
893
|
return !0;
|
|
900
|
-
const
|
|
901
|
-
return
|
|
894
|
+
const c = o.replaceSelectionWith(i).insert(l, a), d = Ze.findFrom(c.doc.resolve(l), 1, !0);
|
|
895
|
+
return d && r(c.setSelection(d).scrollIntoView()), !0;
|
|
902
896
|
});
|
|
903
897
|
n(mt, {
|
|
904
898
|
displayName: "Command<insertHrCommand>",
|
|
905
899
|
group: "Hr"
|
|
906
900
|
});
|
|
907
|
-
const Be =
|
|
901
|
+
const Be = I("bulletList");
|
|
908
902
|
n(Be, {
|
|
909
903
|
displayName: "Attr<bulletList>",
|
|
910
904
|
group: "BulletList"
|
|
911
905
|
});
|
|
912
|
-
const
|
|
906
|
+
const R = C("bullet_list", (t) => ({
|
|
913
907
|
content: "listItem+",
|
|
914
908
|
group: "block",
|
|
915
909
|
attrs: {
|
|
@@ -922,7 +916,7 @@ const K = I("bullet_list", (t) => ({
|
|
|
922
916
|
tag: "ul",
|
|
923
917
|
getAttrs: (e) => {
|
|
924
918
|
if (!(e instanceof HTMLElement))
|
|
925
|
-
throw
|
|
919
|
+
throw A(e);
|
|
926
920
|
return {
|
|
927
921
|
spread: e.dataset.spread
|
|
928
922
|
};
|
|
@@ -951,47 +945,47 @@ const K = I("bullet_list", (t) => ({
|
|
|
951
945
|
}
|
|
952
946
|
}
|
|
953
947
|
}));
|
|
954
|
-
n(
|
|
948
|
+
n(R.node, {
|
|
955
949
|
displayName: "NodeSchema<bulletList>",
|
|
956
950
|
group: "BulletList"
|
|
957
951
|
});
|
|
958
|
-
n(
|
|
952
|
+
n(R.ctx, {
|
|
959
953
|
displayName: "NodeSchemaCtx<bulletList>",
|
|
960
954
|
group: "BulletList"
|
|
961
955
|
});
|
|
962
|
-
const ut =
|
|
956
|
+
const ut = w((t) => re(/^\s*([-+*])\s$/, R.type(t)));
|
|
963
957
|
n(ut, {
|
|
964
958
|
displayName: "InputRule<wrapInBulletListInputRule>",
|
|
965
959
|
group: "BulletList"
|
|
966
960
|
});
|
|
967
|
-
const
|
|
968
|
-
n(
|
|
961
|
+
const Oe = h("WrapInBulletList", (t) => () => te(R.type(t)));
|
|
962
|
+
n(Oe, {
|
|
969
963
|
displayName: "Command<wrapInBulletListCommand>",
|
|
970
964
|
group: "BulletList"
|
|
971
965
|
});
|
|
972
|
-
const
|
|
966
|
+
const Te = N("bulletListKeymap", {
|
|
973
967
|
WrapInBulletList: {
|
|
974
968
|
shortcuts: "Mod-Alt-8",
|
|
975
969
|
command: (t) => {
|
|
976
|
-
const e = t.get(
|
|
977
|
-
return () => e.call(
|
|
970
|
+
const e = t.get(y);
|
|
971
|
+
return () => e.call(Oe.key);
|
|
978
972
|
}
|
|
979
973
|
}
|
|
980
974
|
});
|
|
981
|
-
n(
|
|
975
|
+
n(Te.ctx, {
|
|
982
976
|
displayName: "KeymapCtx<bulletListKeymap>",
|
|
983
977
|
group: "BulletList"
|
|
984
978
|
});
|
|
985
|
-
n(
|
|
979
|
+
n(Te.shortcuts, {
|
|
986
980
|
displayName: "Keymap<bulletListKeymap>",
|
|
987
981
|
group: "BulletList"
|
|
988
982
|
});
|
|
989
|
-
const Ke =
|
|
983
|
+
const Ke = I("orderedList");
|
|
990
984
|
n(Ke, {
|
|
991
985
|
displayName: "Attr<orderedList>",
|
|
992
986
|
group: "OrderedList"
|
|
993
987
|
});
|
|
994
|
-
const
|
|
988
|
+
const P = C("ordered_list", (t) => ({
|
|
995
989
|
content: "listItem+",
|
|
996
990
|
group: "block",
|
|
997
991
|
attrs: {
|
|
@@ -1007,7 +1001,7 @@ const D = I("ordered_list", (t) => ({
|
|
|
1007
1001
|
tag: "ol",
|
|
1008
1002
|
getAttrs: (e) => {
|
|
1009
1003
|
if (!(e instanceof HTMLElement))
|
|
1010
|
-
throw
|
|
1004
|
+
throw A(e);
|
|
1011
1005
|
return {
|
|
1012
1006
|
spread: e.dataset.spread,
|
|
1013
1007
|
order: e.hasAttribute("start") ? Number(e.getAttribute("start")) : 1
|
|
@@ -1038,34 +1032,34 @@ const D = I("ordered_list", (t) => ({
|
|
|
1038
1032
|
}
|
|
1039
1033
|
}
|
|
1040
1034
|
}));
|
|
1041
|
-
n(
|
|
1035
|
+
n(P.node, {
|
|
1042
1036
|
displayName: "NodeSchema<orderedList>",
|
|
1043
1037
|
group: "OrderedList"
|
|
1044
1038
|
});
|
|
1045
|
-
n(
|
|
1039
|
+
n(P.ctx, {
|
|
1046
1040
|
displayName: "NodeSchemaCtx<orderedList>",
|
|
1047
1041
|
group: "OrderedList"
|
|
1048
1042
|
});
|
|
1049
|
-
const pt =
|
|
1043
|
+
const pt = w((t) => re(
|
|
1050
1044
|
/^\s*(\d+)\.\s$/,
|
|
1051
|
-
|
|
1052
|
-
(
|
|
1053
|
-
(
|
|
1045
|
+
P.type(t),
|
|
1046
|
+
(e) => ({ order: Number(e[1]) }),
|
|
1047
|
+
(e, r) => r.childCount + r.attrs.order === Number(e[1])
|
|
1054
1048
|
));
|
|
1055
1049
|
n(pt, {
|
|
1056
1050
|
displayName: "InputRule<wrapInOrderedListInputRule>",
|
|
1057
1051
|
group: "OrderedList"
|
|
1058
1052
|
});
|
|
1059
|
-
const De =
|
|
1053
|
+
const De = h("WrapInOrderedList", (t) => () => te(P.type(t)));
|
|
1060
1054
|
n(De, {
|
|
1061
1055
|
displayName: "Command<wrapInOrderedListCommand>",
|
|
1062
1056
|
group: "OrderedList"
|
|
1063
1057
|
});
|
|
1064
|
-
const Re =
|
|
1058
|
+
const Re = N("orderedListKeymap", {
|
|
1065
1059
|
WrapInOrderedList: {
|
|
1066
1060
|
shortcuts: "Mod-Alt-7",
|
|
1067
1061
|
command: (t) => {
|
|
1068
|
-
const e = t.get(
|
|
1062
|
+
const e = t.get(y);
|
|
1069
1063
|
return () => e.call(De.key);
|
|
1070
1064
|
}
|
|
1071
1065
|
}
|
|
@@ -1078,12 +1072,12 @@ n(Re.shortcuts, {
|
|
|
1078
1072
|
displayName: "Keymap<orderedList>",
|
|
1079
1073
|
group: "OrderedList"
|
|
1080
1074
|
});
|
|
1081
|
-
const Pe =
|
|
1075
|
+
const Pe = I("listItem");
|
|
1082
1076
|
n(Pe, {
|
|
1083
1077
|
displayName: "Attr<listItem>",
|
|
1084
1078
|
group: "ListItem"
|
|
1085
1079
|
});
|
|
1086
|
-
const
|
|
1080
|
+
const M = C("list_item", (t) => ({
|
|
1087
1081
|
group: "listItem",
|
|
1088
1082
|
content: "paragraph block*",
|
|
1089
1083
|
attrs: {
|
|
@@ -1103,7 +1097,7 @@ const C = I("list_item", (t) => ({
|
|
|
1103
1097
|
tag: "li",
|
|
1104
1098
|
getAttrs: (e) => {
|
|
1105
1099
|
if (!(e instanceof HTMLElement))
|
|
1106
|
-
throw
|
|
1100
|
+
throw A(e);
|
|
1107
1101
|
return {
|
|
1108
1102
|
label: e.dataset.label,
|
|
1109
1103
|
listType: e.dataset["list-type"],
|
|
@@ -1125,8 +1119,8 @@ const C = I("list_item", (t) => ({
|
|
|
1125
1119
|
parseMarkdown: {
|
|
1126
1120
|
match: ({ type: e }) => e === "listItem",
|
|
1127
1121
|
runner: (e, r, a) => {
|
|
1128
|
-
const o = r.label != null ? `${r.label}.` : "•", s = r.label != null ? "ordered" : "bullet",
|
|
1129
|
-
e.openNode(a, { label: o, listType: s, spread:
|
|
1122
|
+
const o = r.label != null ? `${r.label}.` : "•", s = r.label != null ? "ordered" : "bullet", l = r.spread != null ? `${r.spread}` : "true";
|
|
1123
|
+
e.openNode(a, { label: o, listType: s, spread: l }), e.next(r.children), e.closeNode();
|
|
1130
1124
|
}
|
|
1131
1125
|
},
|
|
1132
1126
|
toMarkdown: {
|
|
@@ -1136,69 +1130,69 @@ const C = I("list_item", (t) => ({
|
|
|
1136
1130
|
}
|
|
1137
1131
|
}
|
|
1138
1132
|
}));
|
|
1139
|
-
n(
|
|
1133
|
+
n(M.node, {
|
|
1140
1134
|
displayName: "NodeSchema<listItem>",
|
|
1141
1135
|
group: "ListItem"
|
|
1142
1136
|
});
|
|
1143
|
-
n(
|
|
1137
|
+
n(M.ctx, {
|
|
1144
1138
|
displayName: "NodeSchemaCtx<listItem>",
|
|
1145
1139
|
group: "ListItem"
|
|
1146
1140
|
});
|
|
1147
|
-
const Ee =
|
|
1141
|
+
const Ee = h("SinkListItem", (t) => () => Kt(M.type(t)));
|
|
1148
1142
|
n(Ee, {
|
|
1149
1143
|
displayName: "Command<sinkListItemCommand>",
|
|
1150
1144
|
group: "ListItem"
|
|
1151
1145
|
});
|
|
1152
|
-
const _e =
|
|
1146
|
+
const _e = h("SplitListItem", (t) => () => et(M.type(t)));
|
|
1153
1147
|
n(_e, {
|
|
1154
1148
|
displayName: "Command<liftListItemCommand>",
|
|
1155
1149
|
group: "ListItem"
|
|
1156
1150
|
});
|
|
1157
|
-
const $e =
|
|
1151
|
+
const $e = h("SplitListItem", (t) => () => Dt(M.type(t)));
|
|
1158
1152
|
n($e, {
|
|
1159
1153
|
displayName: "Command<splitListItemCommand>",
|
|
1160
1154
|
group: "ListItem"
|
|
1161
1155
|
});
|
|
1162
|
-
const Ft = (t
|
|
1163
|
-
const { selection:
|
|
1164
|
-
if (!(
|
|
1156
|
+
const Ft = (t) => (e, r, a) => {
|
|
1157
|
+
const { selection: o } = e;
|
|
1158
|
+
if (!(o instanceof G))
|
|
1165
1159
|
return !1;
|
|
1166
|
-
const { empty:
|
|
1167
|
-
if (!
|
|
1160
|
+
const { empty: s, $from: l } = o;
|
|
1161
|
+
if (!s || l.parentOffset !== 0)
|
|
1168
1162
|
return !1;
|
|
1169
|
-
const i =
|
|
1170
|
-
return i.type !==
|
|
1171
|
-
}, qe =
|
|
1163
|
+
const i = l.node(-1);
|
|
1164
|
+
return i.type !== M.type(t) || i.firstChild !== l.node() || l.node(-2).childCount > 1 ? !1 : et(M.type(t))(e, r, a);
|
|
1165
|
+
}, qe = h("LiftFirstListItem", (t) => () => Ft(t));
|
|
1172
1166
|
n(qe, {
|
|
1173
1167
|
displayName: "Command<liftFirstListItemCommand>",
|
|
1174
1168
|
group: "ListItem"
|
|
1175
1169
|
});
|
|
1176
|
-
const We =
|
|
1170
|
+
const We = N("listItemKeymap", {
|
|
1177
1171
|
NextListItem: {
|
|
1178
1172
|
shortcuts: "Enter",
|
|
1179
1173
|
command: (t) => {
|
|
1180
|
-
const e = t.get(
|
|
1174
|
+
const e = t.get(y);
|
|
1181
1175
|
return () => e.call($e.key);
|
|
1182
1176
|
}
|
|
1183
1177
|
},
|
|
1184
1178
|
SinkListItem: {
|
|
1185
1179
|
shortcuts: ["Tab", "Mod-]"],
|
|
1186
1180
|
command: (t) => {
|
|
1187
|
-
const e = t.get(
|
|
1181
|
+
const e = t.get(y);
|
|
1188
1182
|
return () => e.call(Ee.key);
|
|
1189
1183
|
}
|
|
1190
1184
|
},
|
|
1191
1185
|
LiftListItem: {
|
|
1192
1186
|
shortcuts: ["Shift-Tab", "Mod-["],
|
|
1193
1187
|
command: (t) => {
|
|
1194
|
-
const e = t.get(
|
|
1188
|
+
const e = t.get(y);
|
|
1195
1189
|
return () => e.call(_e.key);
|
|
1196
1190
|
}
|
|
1197
1191
|
},
|
|
1198
1192
|
LiftFirstListItem: {
|
|
1199
1193
|
shortcuts: ["Backspace", "Delete"],
|
|
1200
1194
|
command: (t) => {
|
|
1201
|
-
const e = t.get(
|
|
1195
|
+
const e = t.get(y);
|
|
1202
1196
|
return () => e.call(qe.key);
|
|
1203
1197
|
}
|
|
1204
1198
|
}
|
|
@@ -1230,12 +1224,12 @@ n(gt, {
|
|
|
1230
1224
|
displayName: "NodeSchema<text>",
|
|
1231
1225
|
group: "Text"
|
|
1232
1226
|
});
|
|
1233
|
-
const Fe =
|
|
1227
|
+
const Fe = I("html");
|
|
1234
1228
|
n(Fe, {
|
|
1235
1229
|
displayName: "Attr<html>",
|
|
1236
1230
|
group: "Html"
|
|
1237
1231
|
});
|
|
1238
|
-
const Ge =
|
|
1232
|
+
const Ge = C("html", (t) => ({
|
|
1239
1233
|
atom: !0,
|
|
1240
1234
|
group: "inline",
|
|
1241
1235
|
inline: !0,
|
|
@@ -1282,12 +1276,12 @@ n(Ge.ctx, {
|
|
|
1282
1276
|
const Gt = [
|
|
1283
1277
|
nt,
|
|
1284
1278
|
ge,
|
|
1285
|
-
|
|
1286
|
-
|
|
1279
|
+
v,
|
|
1280
|
+
Y,
|
|
1287
1281
|
ke,
|
|
1288
|
-
|
|
1282
|
+
H,
|
|
1289
1283
|
we,
|
|
1290
|
-
|
|
1284
|
+
S,
|
|
1291
1285
|
Ie,
|
|
1292
1286
|
q,
|
|
1293
1287
|
be,
|
|
@@ -1295,21 +1289,21 @@ const Gt = [
|
|
|
1295
1289
|
He,
|
|
1296
1290
|
F,
|
|
1297
1291
|
Se,
|
|
1298
|
-
|
|
1292
|
+
D,
|
|
1299
1293
|
Be,
|
|
1300
|
-
|
|
1294
|
+
R,
|
|
1301
1295
|
Ke,
|
|
1302
|
-
|
|
1296
|
+
P,
|
|
1303
1297
|
Pe,
|
|
1304
|
-
|
|
1298
|
+
M,
|
|
1305
1299
|
ne,
|
|
1306
|
-
|
|
1300
|
+
z,
|
|
1307
1301
|
le,
|
|
1308
|
-
|
|
1302
|
+
U,
|
|
1309
1303
|
de,
|
|
1310
|
-
|
|
1304
|
+
x,
|
|
1311
1305
|
pe,
|
|
1312
|
-
|
|
1306
|
+
B,
|
|
1313
1307
|
Fe,
|
|
1314
1308
|
Ge,
|
|
1315
1309
|
gt
|
|
@@ -1323,15 +1317,15 @@ const Gt = [
|
|
|
1323
1317
|
].flat(), jt = [
|
|
1324
1318
|
he,
|
|
1325
1319
|
Ce,
|
|
1326
|
-
|
|
1320
|
+
b,
|
|
1327
1321
|
fe,
|
|
1328
|
-
|
|
1322
|
+
Le,
|
|
1329
1323
|
Ae,
|
|
1330
1324
|
mt,
|
|
1331
1325
|
it,
|
|
1332
1326
|
ct,
|
|
1333
1327
|
De,
|
|
1334
|
-
|
|
1328
|
+
Oe,
|
|
1335
1329
|
Ee,
|
|
1336
1330
|
$e,
|
|
1337
1331
|
_e,
|
|
@@ -1343,21 +1337,21 @@ const Gt = [
|
|
|
1343
1337
|
at
|
|
1344
1338
|
], zt = [
|
|
1345
1339
|
Me,
|
|
1346
|
-
|
|
1340
|
+
xe,
|
|
1347
1341
|
ve,
|
|
1348
1342
|
Ne,
|
|
1349
1343
|
We,
|
|
1350
1344
|
Re,
|
|
1351
|
-
|
|
1345
|
+
Te,
|
|
1352
1346
|
ye,
|
|
1353
1347
|
se,
|
|
1354
1348
|
ue,
|
|
1355
1349
|
ce
|
|
1356
|
-
].flat(), Ut = /\[([^\]]+)]\([^\s\]]+\)/,
|
|
1357
|
-
let e = t, r = e.match(
|
|
1350
|
+
].flat(), Ut = /\[([^\]]+)]\([^\s\]]+\)/, Q = /\[(?<span>((www|https:\/\/|http:\/\/)[^\s\]]+))]\((?<url>[^\s\]]+)\)/, Yt = (t) => new RegExp(`\\\\(?=[^\\w\\s${t}\\\\]|_)`, "g"), Jt = (t) => {
|
|
1351
|
+
let e = t, r = e.match(Q);
|
|
1358
1352
|
for (; r && r.groups; ) {
|
|
1359
1353
|
const { span: a } = r.groups;
|
|
1360
|
-
e = e.replace(
|
|
1354
|
+
e = e.replace(Q, a), r = e.match(Q);
|
|
1361
1355
|
}
|
|
1362
1356
|
return e;
|
|
1363
1357
|
}, Qt = (t, e, r) => {
|
|
@@ -1369,15 +1363,15 @@ const Gt = [
|
|
|
1369
1363
|
}, er = (t, e, r) => {
|
|
1370
1364
|
let a = e, o = !1;
|
|
1371
1365
|
return t.descendants((s) => {
|
|
1372
|
-
var
|
|
1366
|
+
var l;
|
|
1373
1367
|
if (o)
|
|
1374
1368
|
return !1;
|
|
1375
1369
|
if (!s.textContent.includes(r))
|
|
1376
1370
|
return a += s.nodeSize, !1;
|
|
1377
1371
|
if (s.isText) {
|
|
1378
|
-
const
|
|
1379
|
-
if (
|
|
1380
|
-
return o = !0, a +=
|
|
1372
|
+
const i = (l = s.text) == null ? void 0 : l.indexOf(r);
|
|
1373
|
+
if (i != null && i >= 0)
|
|
1374
|
+
return o = !0, a += i, !1;
|
|
1381
1375
|
}
|
|
1382
1376
|
return a += 1, !0;
|
|
1383
1377
|
}), a;
|
|
@@ -1396,28 +1390,28 @@ const Gt = [
|
|
|
1396
1390
|
e = Qt(e, a, a + 1), a = a + 1;
|
|
1397
1391
|
return e;
|
|
1398
1392
|
}
|
|
1399
|
-
},
|
|
1400
|
-
n(
|
|
1393
|
+
}, E = Z(tr, "inlineSyncConfig");
|
|
1394
|
+
n(E, {
|
|
1401
1395
|
displayName: "Ctx<inlineSyncConfig>",
|
|
1402
1396
|
group: "Prose"
|
|
1403
1397
|
});
|
|
1404
1398
|
const rr = (t) => t.selection.$from.node(), ar = (t, e, r, a) => {
|
|
1405
|
-
const o = t.get(
|
|
1399
|
+
const o = t.get(vt), s = e.schema.topNodeType.create(void 0, [r, ...a]);
|
|
1406
1400
|
return o(s);
|
|
1407
1401
|
}, nr = (t, e) => {
|
|
1408
|
-
const r = t.get(
|
|
1402
|
+
const r = t.get(E.key), a = r.placeholderConfig.hole, [o = "", ...s] = e.split(`
|
|
1409
1403
|
|
|
1410
|
-
`),
|
|
1411
|
-
let c =
|
|
1404
|
+
`), l = (m) => r.movePlaceholder(a, m);
|
|
1405
|
+
let c = At(Xt(a), l, Jt)(o);
|
|
1412
1406
|
const d = Zt(r.placeholderConfig)(c);
|
|
1413
1407
|
return c = c.replace(a, d), c = [c, ...s].join(`
|
|
1414
1408
|
|
|
1415
1409
|
`), [c, d];
|
|
1416
1410
|
}, or = (t, e) => {
|
|
1417
|
-
const a = t.get(
|
|
1411
|
+
const a = t.get(Ht)(e);
|
|
1418
1412
|
return a ? a.firstChild : null;
|
|
1419
1413
|
}, sr = (t, e) => {
|
|
1420
|
-
const { globalNodes: r } = t.get(
|
|
1414
|
+
const { globalNodes: r } = t.get(E.key), a = [];
|
|
1421
1415
|
return e.doc.descendants((o) => {
|
|
1422
1416
|
if (r.includes(o.type.name) || r.includes(o.type))
|
|
1423
1417
|
return a.push(o), !1;
|
|
@@ -1426,52 +1420,52 @@ const rr = (t) => t.selection.$from.node(), ar = (t, e, r, a) => {
|
|
|
1426
1420
|
|
|
1427
1421
|
`)[0] || "", ir = (t) => t.childCount === 1 && t.child(0).type.name === "html", ht = (t, e) => {
|
|
1428
1422
|
try {
|
|
1429
|
-
const r = sr(t, e), a = rr(e), o = ar(t, e, a, r), [s,
|
|
1430
|
-
return !
|
|
1431
|
-
var
|
|
1432
|
-
const m = c.marks.find((
|
|
1433
|
-
m && ((
|
|
1423
|
+
const r = sr(t, e), a = rr(e), o = ar(t, e, a, r), [s, l] = nr(t, o), i = or(t, s);
|
|
1424
|
+
return !i || a.type !== i.type || ir(i) ? null : (i.attrs = { ...a.attrs }, i.descendants((c) => {
|
|
1425
|
+
var p;
|
|
1426
|
+
const m = c.marks.find((u) => u.type.name === "link");
|
|
1427
|
+
m && ((p = c.text) != null && p.includes(l)) && m.attrs.href.includes(l) && (m.attrs.href = m.attrs.href.replace(l, ""));
|
|
1434
1428
|
}), {
|
|
1435
1429
|
text: lr(s),
|
|
1436
1430
|
prevNode: a,
|
|
1437
|
-
nextNode:
|
|
1438
|
-
placeholder:
|
|
1431
|
+
nextNode: i,
|
|
1432
|
+
placeholder: l
|
|
1439
1433
|
});
|
|
1440
1434
|
} catch {
|
|
1441
1435
|
return null;
|
|
1442
1436
|
}
|
|
1443
1437
|
}, cr = (t, e, r, a, o) => {
|
|
1444
|
-
var
|
|
1445
|
-
const { placeholderConfig: s } = t.get(
|
|
1446
|
-
let
|
|
1447
|
-
const c = r.apply(
|
|
1438
|
+
var L;
|
|
1439
|
+
const { placeholderConfig: s } = t.get(E.key), l = s.hole;
|
|
1440
|
+
let i = r.tr.setMeta(e, !0).insertText(l, r.selection.from);
|
|
1441
|
+
const c = r.apply(i), d = ht(t, c);
|
|
1448
1442
|
if (!d)
|
|
1449
1443
|
return;
|
|
1450
|
-
const m = d.text.slice(0, d.text.indexOf(d.placeholder)), { $from:
|
|
1451
|
-
|
|
1452
|
-
|
|
1453
|
-
}), a(
|
|
1454
|
-
}, yt =
|
|
1444
|
+
const m = d.text.slice(0, d.text.indexOf(d.placeholder)), { $from: p } = c.selection, u = p.before(), k = p.after(), g = er(d.nextNode, u, d.placeholder);
|
|
1445
|
+
i = i.replaceWith(u, k, d.nextNode).setNodeMarkup(u, void 0, o).delete(g + 1, g + 2), i = i.setSelection(G.near(i.doc.resolve(g + 1))), (Ut.test(m) || ["*", "_", "~"].includes(m.at(-1) || "")) && i.selection instanceof G && (((L = i.selection.$cursor) == null ? void 0 : L.marks()) ?? []).forEach((J) => {
|
|
1446
|
+
i = i.removeStoredMark(J.type);
|
|
1447
|
+
}), a(i);
|
|
1448
|
+
}, yt = O((t) => {
|
|
1455
1449
|
let e = null;
|
|
1456
|
-
const r = new
|
|
1457
|
-
return new
|
|
1450
|
+
const r = new T("MILKDOWN_INLINE_SYNC");
|
|
1451
|
+
return new K({
|
|
1458
1452
|
key: r,
|
|
1459
1453
|
state: {
|
|
1460
1454
|
init: () => null,
|
|
1461
|
-
apply: (a, o, s,
|
|
1462
|
-
var
|
|
1463
|
-
const
|
|
1464
|
-
if (!((
|
|
1455
|
+
apply: (a, o, s, l) => {
|
|
1456
|
+
var g;
|
|
1457
|
+
const i = t.get(X);
|
|
1458
|
+
if (!((g = i.hasFocus) != null && g.call(i)) || !i.editable || !a.docChanged || a.getMeta(r))
|
|
1465
1459
|
return null;
|
|
1466
|
-
const d = ht(t,
|
|
1460
|
+
const d = ht(t, l);
|
|
1467
1461
|
if (!d)
|
|
1468
1462
|
return null;
|
|
1469
1463
|
e && (cancelAnimationFrame(e), e = null);
|
|
1470
|
-
const { prevNode: m, nextNode:
|
|
1471
|
-
return
|
|
1464
|
+
const { prevNode: m, nextNode: p, text: u } = d, { shouldSyncNode: k } = t.get(E.key);
|
|
1465
|
+
return k({ prevNode: m, nextNode: p, ctx: t, tr: a, text: u }) && (e = requestAnimationFrame(() => {
|
|
1472
1466
|
e = null;
|
|
1473
|
-
const { dispatch:
|
|
1474
|
-
cr(t, r,
|
|
1467
|
+
const { dispatch: f, state: L } = t.get(X);
|
|
1468
|
+
cr(t, r, L, f, m.attrs);
|
|
1475
1469
|
})), null;
|
|
1476
1470
|
}
|
|
1477
1471
|
}
|
|
@@ -1501,15 +1495,15 @@ const ft = $(() => () => (t) => {
|
|
|
1501
1495
|
if (!r.value || typeof r.value != "string")
|
|
1502
1496
|
return;
|
|
1503
1497
|
const s = [];
|
|
1504
|
-
let
|
|
1498
|
+
let l = 0;
|
|
1505
1499
|
e.lastIndex = 0;
|
|
1506
|
-
let
|
|
1507
|
-
for (;
|
|
1508
|
-
const d =
|
|
1509
|
-
|
|
1500
|
+
let i = e.exec(r.value);
|
|
1501
|
+
for (; i; ) {
|
|
1502
|
+
const d = i.index;
|
|
1503
|
+
l !== d && s.push({ type: "text", value: r.value.slice(l, d) }), s.push({ type: "break", data: { isInline: !0 } }), l = d + i[0].length, i = e.exec(r.value);
|
|
1510
1504
|
}
|
|
1511
1505
|
if (s.length > 0 && o && typeof a == "number")
|
|
1512
|
-
return
|
|
1506
|
+
return l < r.value.length && s.push({ type: "text", value: r.value.slice(l) }), o.children.splice(a, 1, ...s), a + s.length;
|
|
1513
1507
|
});
|
|
1514
1508
|
});
|
|
1515
1509
|
n(ft, {
|
|
@@ -1526,19 +1520,19 @@ function ur(t, e) {
|
|
|
1526
1520
|
return r(t, 0, null)[0];
|
|
1527
1521
|
function r(a, o, s) {
|
|
1528
1522
|
if (dr(a)) {
|
|
1529
|
-
const
|
|
1530
|
-
for (let
|
|
1531
|
-
const d = a.children[
|
|
1523
|
+
const l = [];
|
|
1524
|
+
for (let i = 0, c = a.children.length; i < c; i++) {
|
|
1525
|
+
const d = a.children[i];
|
|
1532
1526
|
if (d) {
|
|
1533
|
-
const m = r(d,
|
|
1527
|
+
const m = r(d, i, a);
|
|
1534
1528
|
if (m)
|
|
1535
|
-
for (let
|
|
1536
|
-
const
|
|
1537
|
-
|
|
1529
|
+
for (let p = 0, u = m.length; p < u; p++) {
|
|
1530
|
+
const k = m[p];
|
|
1531
|
+
k && l.push(k);
|
|
1538
1532
|
}
|
|
1539
1533
|
}
|
|
1540
1534
|
}
|
|
1541
|
-
a.children =
|
|
1535
|
+
a.children = l;
|
|
1542
1536
|
}
|
|
1543
1537
|
return e(a, o, s);
|
|
1544
1538
|
}
|
|
@@ -1560,9 +1554,9 @@ n(Ct, {
|
|
|
1560
1554
|
displayName: "Remark<remarkMarker>",
|
|
1561
1555
|
group: "Remark"
|
|
1562
1556
|
});
|
|
1563
|
-
const Mt =
|
|
1557
|
+
const Mt = O(() => {
|
|
1564
1558
|
let t = !1;
|
|
1565
|
-
const e = new
|
|
1559
|
+
const e = new T("MILKDOWN_INLINE_NODES_CURSOR"), r = new K({
|
|
1566
1560
|
key: e,
|
|
1567
1561
|
state: {
|
|
1568
1562
|
init() {
|
|
@@ -1571,34 +1565,34 @@ const Mt = H(() => {
|
|
|
1571
1565
|
apply(a) {
|
|
1572
1566
|
if (!a.selection.empty)
|
|
1573
1567
|
return !1;
|
|
1574
|
-
const o = a.selection.$from, s = o.nodeBefore,
|
|
1575
|
-
return !!(s &&
|
|
1568
|
+
const o = a.selection.$from, s = o.nodeBefore, l = o.nodeAfter;
|
|
1569
|
+
return !!(s && l && s.isInline && !s.isText && l.isInline && !l.isText);
|
|
1576
1570
|
}
|
|
1577
1571
|
},
|
|
1578
1572
|
props: {
|
|
1579
1573
|
handleDOMEvents: {
|
|
1580
1574
|
compositionend: (a, o) => t ? (t = !1, requestAnimationFrame(() => {
|
|
1581
1575
|
if (r.getState(a.state)) {
|
|
1582
|
-
const
|
|
1583
|
-
o.preventDefault(), a.dispatch(a.state.tr.insertText(o.data || "",
|
|
1576
|
+
const l = a.state.selection.from;
|
|
1577
|
+
o.preventDefault(), a.dispatch(a.state.tr.insertText(o.data || "", l));
|
|
1584
1578
|
}
|
|
1585
1579
|
}), !0) : !1,
|
|
1586
1580
|
compositionstart: (a) => (r.getState(a.state) && (t = !0), !1),
|
|
1587
1581
|
beforeinput: (a, o) => {
|
|
1588
1582
|
if (r.getState(a.state) && o instanceof InputEvent && o.data && !t) {
|
|
1589
|
-
const
|
|
1590
|
-
return o.preventDefault(), a.dispatch(a.state.tr.insertText(o.data || "",
|
|
1583
|
+
const l = a.state.selection.from;
|
|
1584
|
+
return o.preventDefault(), a.dispatch(a.state.tr.insertText(o.data || "", l)), !0;
|
|
1591
1585
|
}
|
|
1592
1586
|
return !1;
|
|
1593
1587
|
}
|
|
1594
1588
|
},
|
|
1595
1589
|
decorations(a) {
|
|
1596
1590
|
if (r.getState(a)) {
|
|
1597
|
-
const
|
|
1591
|
+
const l = a.selection.$from.pos, i = document.createElement("span"), c = ze.widget(l, i, {
|
|
1598
1592
|
side: -1
|
|
1599
|
-
}), d = document.createElement("span"), m = ze.widget(
|
|
1593
|
+
}), d = document.createElement("span"), m = ze.widget(l, d);
|
|
1600
1594
|
return setTimeout(() => {
|
|
1601
|
-
|
|
1595
|
+
i.contentEditable = "true", d.contentEditable = "true";
|
|
1602
1596
|
}), Ue.create(a.doc, [c, m]);
|
|
1603
1597
|
}
|
|
1604
1598
|
return Ue.empty;
|
|
@@ -1611,27 +1605,27 @@ n(Mt, {
|
|
|
1611
1605
|
displayName: "Prose<inlineNodesCursorPlugin>",
|
|
1612
1606
|
group: "Prose"
|
|
1613
1607
|
});
|
|
1614
|
-
const bt =
|
|
1615
|
-
key: new
|
|
1616
|
-
appendTransaction: (
|
|
1617
|
-
if (!
|
|
1608
|
+
const bt = O((t) => new K({
|
|
1609
|
+
key: new T("MILKDOWN_HARDBREAK_MARKS"),
|
|
1610
|
+
appendTransaction: (e, r, a) => {
|
|
1611
|
+
if (!e.length)
|
|
1618
1612
|
return;
|
|
1619
|
-
const [
|
|
1620
|
-
if (!
|
|
1613
|
+
const [o] = e;
|
|
1614
|
+
if (!o)
|
|
1621
1615
|
return;
|
|
1622
|
-
const [
|
|
1623
|
-
if (
|
|
1624
|
-
if (!(
|
|
1616
|
+
const [s] = o.steps;
|
|
1617
|
+
if (o.getMeta("hardbreak")) {
|
|
1618
|
+
if (!(s instanceof Rt))
|
|
1625
1619
|
return;
|
|
1626
|
-
const { from:
|
|
1627
|
-
return
|
|
1620
|
+
const { from: c } = s;
|
|
1621
|
+
return a.tr.setNodeMarkup(c, S.type(t), void 0, []);
|
|
1628
1622
|
}
|
|
1629
|
-
if (
|
|
1630
|
-
let
|
|
1631
|
-
const { from:
|
|
1632
|
-
return
|
|
1633
|
-
|
|
1634
|
-
}),
|
|
1623
|
+
if (s instanceof Pt) {
|
|
1624
|
+
let c = a.tr;
|
|
1625
|
+
const { from: d, to: m } = s;
|
|
1626
|
+
return a.doc.nodesBetween(d, m, (p, u) => {
|
|
1627
|
+
p.type === S.type(t) && (c = c.setNodeMarkup(u, S.type(t), void 0, []));
|
|
1628
|
+
}), c;
|
|
1635
1629
|
}
|
|
1636
1630
|
}
|
|
1637
1631
|
}));
|
|
@@ -1639,51 +1633,51 @@ n(bt, {
|
|
|
1639
1633
|
displayName: "Prose<hardbreakClearMarkPlugin>",
|
|
1640
1634
|
group: "Prose"
|
|
1641
1635
|
});
|
|
1642
|
-
const Ve =
|
|
1636
|
+
const Ve = Z(["table", "code_block"], "hardbreakFilterNodes");
|
|
1643
1637
|
n(Ve, {
|
|
1644
1638
|
displayName: "Ctx<hardbreakFilterNodes>",
|
|
1645
1639
|
group: "Prose"
|
|
1646
1640
|
});
|
|
1647
|
-
const
|
|
1641
|
+
const Lt = O((t) => {
|
|
1648
1642
|
const e = t.get(Ve.key);
|
|
1649
|
-
return new
|
|
1650
|
-
key: new
|
|
1643
|
+
return new K({
|
|
1644
|
+
key: new T("MILKDOWN_HARDBREAK_FILTER"),
|
|
1651
1645
|
filterTransaction: (r, a) => {
|
|
1652
1646
|
const o = r.getMeta("hardbreak"), [s] = r.steps;
|
|
1653
1647
|
if (o && s) {
|
|
1654
|
-
const { from:
|
|
1655
|
-
let c =
|
|
1648
|
+
const { from: l } = s, i = a.doc.resolve(l);
|
|
1649
|
+
let c = i.depth, d = !0;
|
|
1656
1650
|
for (; c > 0; )
|
|
1657
|
-
e.includes(
|
|
1651
|
+
e.includes(i.node(c).type.name) && (d = !1), c--;
|
|
1658
1652
|
return d;
|
|
1659
1653
|
}
|
|
1660
1654
|
return !0;
|
|
1661
1655
|
}
|
|
1662
1656
|
});
|
|
1663
1657
|
});
|
|
1664
|
-
n(
|
|
1658
|
+
n(Lt, {
|
|
1665
1659
|
displayName: "Prose<hardbreakFilterPlugin>",
|
|
1666
1660
|
group: "Prose"
|
|
1667
1661
|
});
|
|
1668
|
-
const
|
|
1669
|
-
const e = new
|
|
1662
|
+
const xt = O((t) => {
|
|
1663
|
+
const e = new T("MILKDOWN_HEADING_ID"), r = (a) => {
|
|
1670
1664
|
if (a.composing || !a.editable)
|
|
1671
1665
|
return;
|
|
1672
|
-
const o = t.get(
|
|
1673
|
-
let
|
|
1674
|
-
a.state.doc.descendants((
|
|
1675
|
-
if (
|
|
1676
|
-
if (
|
|
1666
|
+
const o = t.get(Y.key), s = a.state.tr.setMeta("addToHistory", !1);
|
|
1667
|
+
let l = !1;
|
|
1668
|
+
a.state.doc.descendants((i, c) => {
|
|
1669
|
+
if (i.type === H.type(t)) {
|
|
1670
|
+
if (i.textContent.trim().length === 0)
|
|
1677
1671
|
return;
|
|
1678
|
-
const d =
|
|
1679
|
-
d.id !== m && (
|
|
1672
|
+
const d = i.attrs, m = o(i);
|
|
1673
|
+
d.id !== m && (l = !0, s.setMeta(e, !0).setNodeMarkup(c, void 0, {
|
|
1680
1674
|
...d,
|
|
1681
1675
|
id: m
|
|
1682
1676
|
}));
|
|
1683
1677
|
}
|
|
1684
|
-
}),
|
|
1678
|
+
}), l && a.dispatch(s);
|
|
1685
1679
|
};
|
|
1686
|
-
return new
|
|
1680
|
+
return new K({
|
|
1687
1681
|
key: e,
|
|
1688
1682
|
view: (a) => (r(a), {
|
|
1689
1683
|
update: (o) => {
|
|
@@ -1692,42 +1686,42 @@ const Lt = H((t) => {
|
|
|
1692
1686
|
})
|
|
1693
1687
|
});
|
|
1694
1688
|
});
|
|
1695
|
-
n(
|
|
1689
|
+
n(xt, {
|
|
1696
1690
|
displayName: "Prose<syncHeadingIdPlugin>",
|
|
1697
1691
|
group: "Prose"
|
|
1698
1692
|
});
|
|
1699
|
-
const St =
|
|
1700
|
-
const
|
|
1701
|
-
if (
|
|
1693
|
+
const St = O((t) => {
|
|
1694
|
+
const e = (r) => {
|
|
1695
|
+
if (r.composing || !r.editable)
|
|
1702
1696
|
return;
|
|
1703
|
-
const
|
|
1697
|
+
const a = P.type(t), o = R.type(t), s = M.type(t), l = r.state, i = (m, p) => {
|
|
1704
1698
|
let u = !1;
|
|
1705
|
-
const
|
|
1706
|
-
return
|
|
1699
|
+
const k = `${p + 1}.`;
|
|
1700
|
+
return m.label !== k && (m.label = k, u = !0), u;
|
|
1707
1701
|
};
|
|
1708
|
-
let
|
|
1709
|
-
|
|
1710
|
-
if (
|
|
1711
|
-
const
|
|
1712
|
-
(
|
|
1713
|
-
if (
|
|
1714
|
-
const
|
|
1715
|
-
i(
|
|
1702
|
+
let c = l.tr, d = !1;
|
|
1703
|
+
l.doc.descendants((m, p, u, k) => {
|
|
1704
|
+
if (m.type === o) {
|
|
1705
|
+
const g = m.maybeChild(0);
|
|
1706
|
+
(g == null ? void 0 : g.type) === s && g.attrs.listType === "ordered" && (d = !0, c.setNodeMarkup(p, a, { spread: "true" }), m.descendants((f, L, wt, J) => {
|
|
1707
|
+
if (f.type === s) {
|
|
1708
|
+
const je = { ...f.attrs };
|
|
1709
|
+
i(je, J) && (c = c.setNodeMarkup(L, void 0, je));
|
|
1716
1710
|
}
|
|
1717
1711
|
return !1;
|
|
1718
1712
|
}));
|
|
1719
|
-
} else if (
|
|
1720
|
-
const
|
|
1721
|
-
let
|
|
1722
|
-
|
|
1713
|
+
} else if (m.type === s && (u == null ? void 0 : u.type) === a) {
|
|
1714
|
+
const g = { ...m.attrs };
|
|
1715
|
+
let f = !1;
|
|
1716
|
+
g.listType !== "ordered" && (g.listType = "ordered", f = !0), (u == null ? void 0 : u.maybeChild(0)) && (f = i(g, k)), f && (c = c.setNodeMarkup(p, void 0, g), d = !0);
|
|
1723
1717
|
}
|
|
1724
|
-
}),
|
|
1718
|
+
}), d && r.dispatch(c.setMeta("addToHistory", !1));
|
|
1725
1719
|
};
|
|
1726
|
-
return new
|
|
1727
|
-
key: new
|
|
1728
|
-
view: (
|
|
1729
|
-
update: (
|
|
1730
|
-
|
|
1720
|
+
return new K({
|
|
1721
|
+
key: new T("MILKDOWN_KEEP_LIST_ORDER"),
|
|
1722
|
+
view: (r) => (e(r), {
|
|
1723
|
+
update: (a) => {
|
|
1724
|
+
e(a);
|
|
1731
1725
|
}
|
|
1732
1726
|
})
|
|
1733
1727
|
});
|
|
@@ -1737,18 +1731,18 @@ n(St, {
|
|
|
1737
1731
|
group: "Prose"
|
|
1738
1732
|
});
|
|
1739
1733
|
const pr = [
|
|
1740
|
-
|
|
1734
|
+
E,
|
|
1741
1735
|
yt,
|
|
1742
1736
|
bt,
|
|
1743
1737
|
Ve,
|
|
1744
|
-
|
|
1738
|
+
Lt,
|
|
1745
1739
|
Mt,
|
|
1746
1740
|
kt,
|
|
1747
1741
|
Nt,
|
|
1748
1742
|
ft,
|
|
1749
1743
|
It,
|
|
1750
1744
|
Ct,
|
|
1751
|
-
|
|
1745
|
+
xt,
|
|
1752
1746
|
St
|
|
1753
1747
|
], vr = [Gt, Vt, jt, zt, pr].flat();
|
|
1754
1748
|
export {
|
|
@@ -1756,42 +1750,42 @@ export {
|
|
|
1756
1750
|
Me as blockquoteKeymap,
|
|
1757
1751
|
q as blockquoteSchema,
|
|
1758
1752
|
Be as bulletListAttr,
|
|
1759
|
-
|
|
1760
|
-
|
|
1753
|
+
Te as bulletListKeymap,
|
|
1754
|
+
R as bulletListSchema,
|
|
1761
1755
|
be as codeBlockAttr,
|
|
1762
|
-
|
|
1756
|
+
xe as codeBlockKeymap,
|
|
1763
1757
|
W as codeBlockSchema,
|
|
1764
1758
|
jt as commands,
|
|
1765
1759
|
vr as commonmark,
|
|
1766
|
-
|
|
1760
|
+
Le as createCodeBlockCommand,
|
|
1767
1761
|
lt as createCodeBlockInputRule,
|
|
1768
1762
|
tr as defaultConfig,
|
|
1769
1763
|
nt as docSchema,
|
|
1770
1764
|
fe as downgradeHeadingCommand,
|
|
1771
1765
|
ne as emphasisAttr,
|
|
1772
1766
|
se as emphasisKeymap,
|
|
1773
|
-
|
|
1767
|
+
z as emphasisSchema,
|
|
1774
1768
|
we as hardbreakAttr,
|
|
1775
1769
|
bt as hardbreakClearMarkPlugin,
|
|
1776
1770
|
Ve as hardbreakFilterNodes,
|
|
1777
|
-
|
|
1771
|
+
Lt as hardbreakFilterPlugin,
|
|
1778
1772
|
ve as hardbreakKeymap,
|
|
1779
|
-
|
|
1773
|
+
S as hardbreakSchema,
|
|
1780
1774
|
ke as headingAttr,
|
|
1781
|
-
|
|
1775
|
+
Y as headingIdGenerator,
|
|
1782
1776
|
Ne as headingKeymap,
|
|
1783
|
-
|
|
1777
|
+
H as headingSchema,
|
|
1784
1778
|
He as hrAttr,
|
|
1785
1779
|
F as hrSchema,
|
|
1786
1780
|
Fe as htmlAttr,
|
|
1787
1781
|
Ge as htmlSchema,
|
|
1788
1782
|
Se as imageAttr,
|
|
1789
|
-
|
|
1783
|
+
D as imageSchema,
|
|
1790
1784
|
de as inlineCodeAttr,
|
|
1791
1785
|
ue as inlineCodeKeymap,
|
|
1792
|
-
|
|
1786
|
+
x as inlineCodeSchema,
|
|
1793
1787
|
Mt as inlineNodesCursorPlugin,
|
|
1794
|
-
|
|
1788
|
+
E as inlineSyncConfig,
|
|
1795
1789
|
yt as inlineSyncPlugin,
|
|
1796
1790
|
Vt as inputrules,
|
|
1797
1791
|
Ae as insertHardbreakCommand,
|
|
@@ -1803,16 +1797,16 @@ export {
|
|
|
1803
1797
|
qe as liftFirstListItemCommand,
|
|
1804
1798
|
_e as liftListItemCommand,
|
|
1805
1799
|
pe as linkAttr,
|
|
1806
|
-
|
|
1800
|
+
B as linkSchema,
|
|
1807
1801
|
Pe as listItemAttr,
|
|
1808
1802
|
We as listItemKeymap,
|
|
1809
|
-
|
|
1803
|
+
M as listItemSchema,
|
|
1810
1804
|
Ke as orderedListAttr,
|
|
1811
1805
|
Re as orderedListKeymap,
|
|
1812
|
-
|
|
1806
|
+
P as orderedListSchema,
|
|
1813
1807
|
ge as paragraphAttr,
|
|
1814
1808
|
ye as paragraphKeymap,
|
|
1815
|
-
|
|
1809
|
+
v as paragraphSchema,
|
|
1816
1810
|
pr as plugins,
|
|
1817
1811
|
kt as remarkAddOrderInListPlugin,
|
|
1818
1812
|
It as remarkHtmlTransformer,
|
|
@@ -1824,8 +1818,8 @@ export {
|
|
|
1824
1818
|
$e as splitListItemCommand,
|
|
1825
1819
|
le as strongAttr,
|
|
1826
1820
|
ce as strongKeymap,
|
|
1827
|
-
|
|
1828
|
-
|
|
1821
|
+
U as strongSchema,
|
|
1822
|
+
xt as syncHeadingIdPlugin,
|
|
1829
1823
|
St as syncListOrderPlugin,
|
|
1830
1824
|
gt as textSchema,
|
|
1831
1825
|
oe as toggleEmphasisCommand,
|
|
@@ -1838,9 +1832,9 @@ export {
|
|
|
1838
1832
|
at as updateLinkCommand,
|
|
1839
1833
|
Ce as wrapInBlockquoteCommand,
|
|
1840
1834
|
st as wrapInBlockquoteInputRule,
|
|
1841
|
-
|
|
1835
|
+
Oe as wrapInBulletListCommand,
|
|
1842
1836
|
ut as wrapInBulletListInputRule,
|
|
1843
|
-
|
|
1837
|
+
b as wrapInHeadingCommand,
|
|
1844
1838
|
ot as wrapInHeadingInputRule,
|
|
1845
1839
|
De as wrapInOrderedListCommand,
|
|
1846
1840
|
pt as wrapInOrderedListInputRule
|